//
//  SystemSettingViewController.m
//  OutesIOS
//
//  Created by norman on 2018/12/2.
//  Copyright © 2018 norman. All rights reserved.
//

#import "SystemSettingViewController.h"
#import "DiReSettingViewController.h"
#import "MainEquipSettingViewController.h"
#import "RoomSettingViewController.h"
#import "PriceSettingViewController.h"

@interface SystemSettingViewController ()

@property (nonatomic,strong) UITableView *tableView;

@end

@implementation SystemSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupViews];
    // Do any additional setup after loading the view.
}

#pragma mark - 初始化视图
- (void)setupViews{
    self.title = @"系统设置";
    
    self.tableView = ({
        UITableView *tableView = [[UITableView alloc] initWithFrame:[UIView frameWithOutNavTab] style:UITableViewStylePlain];
        tableView.delegate = self;
        tableView.dataSource = self;
        [self.view addSubview:tableView];
        tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
        tableView;
    });
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.tableView.backgroundColor = CM_WINDOW_BG_COLOR;
    //去掉多余的分割线
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    [self.view addSubview:self.tableView];
    //添加tableviewHeader
    //    self.tableView.tableHeaderView = [self addTableViewHeader];
    //    self.tableView.tableFooterView = [self addTableViewFooter];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"Mine_Cell_Identifier";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.textColor = CM_TABLE_TITLE_COLOR;
    cell.textLabel.font = [UIFont systemFontOfSize:kListTitleFontSize];
    
    if (indexPath.section == 0){
        cell.imageView.image = [UIImage imageNamed:@"mine_user_approve"];
        cell.textLabel.text = @"地热盘管设置";
    } else if (indexPath.section == 1) {
        cell.imageView.image = [UIImage imageNamed:@"mine_loginout"];
        cell.textLabel.text = @"主机设置";
    } else if (indexPath.section == 2) {
        cell.imageView.image = [UIImage imageNamed:@"mine_loginout"];
        cell.textLabel.text = @"室内设计条件设置";
    } else {
        cell.imageView.image = [UIImage imageNamed:@"mine_loginout"];
        cell.textLabel.text = @"价格设置";
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.section == 0){
        DiReSettingViewController *vc = [DiReSettingViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    } else if (indexPath.section == 1){
        MainEquipSettingViewController *vc = [MainEquipSettingViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    } else if (indexPath.section == 2){
        RoomSettingViewController *vc = [RoomSettingViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    } else if (indexPath.section == 3){
        PriceSettingViewController *vc = [PriceSettingViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreen_Width, CGFLOAT_MIN)];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreen_Width, CGFLOAT_MIN)];
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
